package com.lagou.edu.service.impl;

import com.lagou.edu.dao.ResumeDao;
import com.lagou.edu.pojo.Resume;
import com.lagou.edu.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

/**
 * @author srh
 * @date 2020/03/20
 **/
@Service(value = "resumeService")
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeDao resumeDao;

    @Override
    public List<Resume> findAll() {
        return resumeDao.findAll();
    }

    @Override
    public void delete(Long id) {
        Assert.notNull(id, "id not be null");
        resumeDao.deleteById(id);
    }

    @Override
    public void insert(Resume resume) {
        Assert.notNull(resume, "insert param not be null");
        resumeDao.save(resume);
    }

    @Override
    public Resume queryById(Long id) {
        Assert.notNull(id, "id not be null");
        return resumeDao.findById(id).orElse(null);
    }

    @Override
    public void update(Resume resume) {
        Assert.notNull(resume, "update param not be null");
        resumeDao.save(resume);
    }
}
